package com.dormitory.service.impl;

import com.dormitory.dao.RoomDao;
import com.dormitory.dao.impl.RoomDaoImpl;
import com.dormitory.model.Room;
import com.dormitory.service.RoomService;

import java.util.List;

public class RoomServiceImpl implements RoomService {
    private RoomDao roomDao = new RoomDaoImpl();

    @Override
    public boolean addRoom(Room room) {
        return roomDao.save(room);
    }

    @Override
    public boolean updateRoom(Room room) {
        return roomDao.update(room);
    }

    @Override
    public boolean deleteRoom(Integer roomId) {
        return roomDao.delete(roomId);
    }

    @Override
    public Room getRoomById(Integer roomId) {
        return roomDao.findById(roomId);
    }

    @Override
    public List<Room> getAllRooms() {
        return roomDao.findAll();
    }

    @Override
    public List<Room> getRoomsByBuildingId(Integer buildingId) {
        return roomDao.findByBuildingId(buildingId);
    }

    @Override
    public List<Room> searchRooms(String condition) {
        return roomDao.findByCondition(condition);
    }
} 